/*
 * ProxClone : Proximity Clone, a war of numbers
 * Copyright (C) 2011-2011 Edi Ermawan <edi.ermawan@gmail.Com>
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */
#ifndef __TILE_ANIM_ALG_A
#define __TILE_ANIM_ALG_A


#include "TileAnimAlgorithm.h"

class TileAnimAlgorithm_A:public TileAnimAlgorithm
{
private:
	int mIndexBot,mIndexTop;
	int mtStart,mtStop;
public:
	TileAnimAlgorithm_A()
	{
		mIndexBot=0;
		mtStart=0;
	}
	void setTiles(std::vector<HexaTile*>& tiles)
	{
		TileAnimAlgorithm::setTiles(tiles);
		mIndexTop=mTiles.size()-1;
	}
	void Render()
	{
		if(mtStart==0)
			mtStart=SDL_GetTicks();

		for(int i=0;i<mIndexBot+1;i++)
		{
			mTiles.at(i)->Render();
		}
		for(int i=(mTiles.size()-1);i>mIndexTop+1;i--)
		{
			mTiles.at(i)->Render();
		}
		if(mIndexBot==((mTiles.size())/2))
			return;
		
		mtStop=SDL_GetTicks();
		if((mtStop-mtStart)>30)
		{
			if(mIndexBot++<((mTiles.size()-1)/2))
			{
				mTiles.at(mIndexBot)->Render();
			}
			if(mIndexTop-->((mTiles.size()-1)/2))
			{
				mTiles.at(mIndexBot)->Render();
			}
			mtStart=0;
		}
	}
};


#endif //

/* Algo A
#ifndef __TILE_ANIM_ALG_A
#define __TILE_ANIM_ALG_A


#include "TileAnimAlgorithm.h"

class TileAnimAlgorithm_A:public TileAnimAlgorithm
{
private:
	int mIndex;
	int mtStart,mtStop;
public:
	TileAnimAlgorithm_A()
	{
		mIndex=0;
		mtStart=0;
	}
	void Render()
	{
		if(mtStart==0)
			mtStart=SDL_GetTicks();
		for(int i=0;i<mIndex+1;i++)
		{
			mTiles.at(i)->Render();
		}
		if(mIndex==(mTiles.size()-1))
			return;
		
		mtStop=SDL_GetTicks();
		if((mtStop-mtStart)>30)
		{
			if(mIndex++<mTiles.size()-1)
			{
				mTiles.at(mIndex)->Render();
			}
			mtStart=0;
		}
	}
};
*/